package dao;

import org.apache.ibatis.annotations.*;
import pojo.Department;

import java.util.List;

public interface DepartmentMapper {

    @Select("select * from department ")
    List<Department> findAll();

    @Select("select * from department where department_id = #{id}")
    Department findById(int id);

    @Insert("insert into department (department_name, level, parent_id, create_time) values (#{department_name}, #{level}, #{parent_id}, #{create_time})")
    @Options(useGeneratedKeys = true, keyProperty = "department_id")
    int addDepartment(Department department);

    @Update("update department set department_name = #{department_name}, level = #{level}, parent_id = #{parent_id}, create_time = #{create_time} where department_id = #{department_id}")
    int updateDepartment(Department department);

    @Delete("delete from department where department_id = #{id}")
    int deleteDepartment(int id);
}